/*
* @Author: taosong
* @Date:   2018-08-24 13:57:17
* @Last Modified by:   taosong
* @Last Modified time: 2018-08-30 19:41:41
*/
export function hasClass(el, className) {
  let reg = new RegExp('(^|\\s)' + className + '(\\s|$)')
  return reg.test(el.className)
}

export function addClass(el, className) {
  if (hasClass(el, className)) {
    return
  }

  let newClass = el.className.split(' ')
  newClass.push(className)
  el.className = newClass.join(' ')
}


export function getDate (el,name,val) {
  const prefix = 'data-'
   // name = prefix + name
  if (val) {
  	return el.setAttribute(prefix + name,val)
  }
   else {
   	return el.getAttribute(prefix + name)
   }
}